package com.webshop.service;
/**
 * 这是随机加载
 */

import com.webshop.DataDao.Picture_uploadDao;
import com.webshop.JavaBean.Goods;
import com.webshop.JavaBean.Picture;

import java.util.Random;

public class PicuploadService {

    //产生随机名字
       public String getPicname(){
           String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
           char[] c = s.toCharArray();
           Random random = new Random();
           String ss="";
           for( int i = 0; i <3; i ++) {
               ss=ss+c[random.nextInt(c.length)];
           }
           return  ss;
       }

    public void insert(Picture picture)throws Exception{
        Picture_uploadDao picture_uploadDao=new Picture_uploadDao();
        picture_uploadDao.upload(picture);
    }
    /**
     * 上传图片
     * @param goods
     */
    public void insertgood(Goods goods){
        try {
            Picture_uploadDao picture_uploadDao=new Picture_uploadDao();
            picture_uploadDao.insertgoods(goods);
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("flase");
        }

    }
    public int selet(String pic){
        int a=0;
        Picture_uploadDao p=new Picture_uploadDao();
        try {
            a=p.selectpic(pic);
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(a);
        return  a;
    }
}
